import React from "react";
import { ListState } from "../../hooks/useFetchList";
import { formatSellCount } from "../../utils/formatSellCount";

interface PorpsType {
  v: ListState;
  onClick?: Function;
}

export const ListItem: React.FC<PorpsType> = ({ v, onClick }) => {
  return (
    <div key={v.id} className="list-item" onClick={() => onClick && onClick()}>
      <img src={v.images[0]} alt="" />
      <div className="con">
        <h3>{v.title}</h3>
        <p>{v.desc}</p>
        <div className="btm">
          <b>
            单价：¥ <span>{v.price}</span>{" "}
          </b>
          <b>已售: {formatSellCount(v.sellCount)}</b>
        </div>
      </div>
    </div>
  );
};
